package com.tantinevincent.option;

public class Option {
	private boolean normalizationFlag = false;
	private boolean mergeFlag = false;
	private boolean shuffleFlag = false;
	private boolean sourcePathListFlag = false;
	private double trainRatio = 1.0;
	
	public void load(String arg){
		//if( arg.equals("-p") ){
		//	sourcePathListFlag = true;
		//	return;
		//}
		if( arg.equals("-n") ){
			normalizationFlag = true;
			return;
		}
		if( arg.equals("-s") ){
			shuffleFlag = true;
			return;
		}
		//if( arg.equals("-m") ){
		//	mergeFlag = true;
		//	return;
		//}
		//if( arg.contains("-r") ){
		//	parserSplitRatioOption(arg);
		//	return;
		//}
		errorProcess("Error in option: option is not correct.");
	}
	private void parserSplitRatioOption(String arg){
		int equalIndex = arg.indexOf('=');
		int colonIndex = arg.indexOf(':');
		if( equalIndex < 0 || colonIndex < 0 || equalIndex > colonIndex ){
			errorProcess("Error in option: ratio format is not correct.");
		}else{
			int trainingNum = Integer.parseInt( arg.substring(equalIndex+1,colonIndex) );
			int testingNum = Integer.parseInt( arg.substring(colonIndex+1) );
			trainRatio = (double)trainingNum / (trainingNum+testingNum);
		}
	}
	private void errorProcess(String s){
		System.err.println(s);
		System.exit(-1);
	}
	public static void printHint(){
		//System.out.println("     -p  source file is path list of source file, default is false");
		System.out.println("     -n : min-max normalization, default option is false ");
		System.out.println("     -s : data shuffle, default is false ");
		//System.out.println("     -m  merge data if data come from mutli-data, before split by ratio,deafult is false");
		//System.out.println("     -r  split by specific ratio, such as '-s=9:1', the training data is 9 and testing data is 1, default option is 10:0");
	}
	public boolean hasNormalization(){
		return normalizationFlag;
	}
	public boolean hasShuffle(){
		return shuffleFlag;
	}
}
